#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>

int main(int argc, char const *argv[])
{
        int n = 5;
        int i = 0;
        pid_t pid;

        for (i = 0; i < n; i++){
                pid = fork();
                if(pid == 0){
                        break;
                }
        }
        
        sleep(i);
        
        if(i < 5){
                printf("I am child, will exit,pid=%d, ppid=%d\n", getpid(), getppid());
        }else{
                printf("I am father, pid = %d, ppid=%d\n", getpid(), getppid());
        }

        return 0;
}
